//定义首页数据
import type { ConsultOrderItem, ConsultOrderListParams, ConsultOrderPage, ConsultOrderPreData, ConsultOrderPreParams, DoctorParams, DoctorRes, Image, KnowledgeParams, KnowledgeResType, LikeDoctorType, PartialConsult, TopDep } from "@/types/consult";
import type { PatientDataType } from "@/types/user";
import { request } from "@/utils/request";
// 首页-查询推荐/减脂/饮食健康/关注页面--百科文章列表
export const getKnowledgeList =(params:KnowledgeParams)=>{
  return request<KnowledgeResType>('/patient/home/knowledge','GET',params)
}

//首页-关注的医生列表
export const getDoctorList =(params:DoctorParams)=>{
  return request<DoctorRes>('/home/page/doc','GET',params)
}

//关注-关注操作
export const likeDoctor = (id:string,type:LikeDoctorType='doc')=>{
  return request('/like','POST',{id,type})
}

//获取科室
export const getAllDep = () => request<TopDep[]>('/dep/all')

//上传文件/图片
export const fileImg = (file:File)=>{
  const fd = new FormData()
  fd.append('file',file)
  return request<Image>('/upload','POST',fd)
}

//问诊-支付页面-计算就诊信息和抵扣信息
export const getConsultOrderPre =(params:ConsultOrderPreParams)=>{
  return request<ConsultOrderPreData>('/patient/consult/order/pre','GET',params)
}

//问诊-查询患者详情
export const getPatientInfo =(id:string)=>{
  return request<PatientDataType>(`/patient/info/${id}`)
}

//问诊-保存/修改问诊订单
export const consultOrderId =(data:PartialConsult)=>{
  return request<{id:string}>('/patient/consult/order','POST',data)
}

//订单-支付接口
export const consultPay = (data:{paymentMethod:0|1,orderId:string,payCallback:string})=>{
  return request<{payUrl:string}>('/patient/consult/pay','POST',data)
}
//查询问诊订单详情
export const getConsultOrderDetail =(orderId:string)=>{
  return request<ConsultOrderItem>('/patient/consult/order/detail','GET',{orderId})
}

// 查看处方
export const getPrescriptionPic = (id: string) =>
request<{ url: string }>(`/patient/consult/prescription/${id}`)

//
export const evaDoc = (data:{
  docId:string,
  orderId:string,
  score:number,
  content:string,
  anonymousFlag:0|1
})=>{
  return request('/patient/order/evaluate','POST',data)
}

//问诊记录-订单列表-找医生、极速问诊、开药问诊
export const ConsultOrderList =(params:ConsultOrderListParams)=>request<ConsultOrderPage>('/patient/consult/order/list','GET',params)

//订单-取消订单
export const getCancelOrder =(id:string)=>request(`/patient/order/cancel/${id}`,'PUT')
//订单-删除订单
export const getDelOrder =(id:string)=>request(`/patient/order/${id}`,'DELETE')